import { HttpVersionPolicy, SslProtocols } from "../services/client";

export const GetSslProtocols = () => {
  const output = []

  for(let key in SslProtocols){
    output.push({
      Value: parseInt(key),
      Label: SslProtocols[key]
    })
  }

  return output
}

export const GetVersionPolicies = () => {
  const pairs = []

  for(let key in HttpVersionPolicy){
    pairs.push({
      Value: key,
      Label: HttpVersionPolicy[key]
    })
  }

  return pairs
}

const ClusterConfigConstants = {
  LoadBalancingPolicies: [
    "PowerOfTwoChoices",
    "FirstAlphabetical",
    "Random",
    "RoundRobin",
    "LeastRequests",
  ],
  SessionAffinity: {
    FailurePolicies: ["Redistribute", "Return503Error"],
    Policies: ["Cookie", "CustomHeader"],
    CookieConfig: {
      SecurePolicies: [
        { Value: 0, Label: 'SameAsRequest'},
        { Value: 1, Label: 'Always'},
        { Value: 2, Label: 'None'}
      ],
      SameSiteModes: [
        { Value: -1, Label: 'Unspecified' },
        { Value: 0, Label: 'None' },
        { Value: 1, Label: 'Lax' },
        { Value: 2, Label: 'Strict' },
      ]
    }
  },
  HealthCheck: {
    Passive: {
      Policies: ["TransportFailureRateHealthPolicy"]
    },
    Active: {
      Policies: ["ConsecutiveFailures"]
    }
  },
  HttpClient: {
    SslProtocols: GetSslProtocols
  },
  HttpRequest: {
    VersionPolicies: [
      {
        Value: HttpVersionPolicy.RequestVersionExact,
        Label: 'RequestVersionExact'
      },
      {
        Value: HttpVersionPolicy.RequestVersionOrHigher,
        Label: 'RequestVersionOrHigher'
      },
      {
        Value: HttpVersionPolicy.RequestVersionOrLower,
        Label: 'RequestVersionOrLower'
      }
    ]
  }
};


export default ClusterConfigConstants